﻿/*---------------------------------------------------------------------------------
-----------------***DaLianQianYi***-----------------------
-----------------作者：大连仟亿科技------------------------------------------------------
-----------------联系作者：www.qianyikeji.com----------------------------------
-----------------时间：2018/8/17 17:44:38------------------------------------------
----------------------------------------------------------------------------------*/

using System.Collections.Generic;
using System.Data;

namespace Donal.Xms.BLL
{
    /// <summary>
    ///数据业务层
    /// </summary>
    public partial class coupons_allotment
    {
        private readonly Model.sysconfig sysConfig;//获得系统配置信息
        private readonly DAL.coupons_allotment dal;

        public coupons_allotment(bool isRuntime = false)
        {
            sysConfig = new BLL.sysconfig().loadConfig();//获得系统配置信息
            dal = new DAL.coupons_allotment(sysConfig.sysdatabaseprefix);
        }

        public coupons_allotment(Model.sysconfig _sysConfig)
        {
            sysConfig = _sysConfig;//获得系统配置信息           
            dal = new DAL.coupons_allotment(sysConfig.sysdatabaseprefix);
        }

        #region 基本方法================================
        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public bool Exists(int id)
        {
            return dal.Exists(id);
        }

        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Model.coupons_allotment model)
        {
            return dal.Add(model);
        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Model.coupons_allotment model)
        {
            return dal.Update(model);
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool Delete(int id)
        {
            return dal.Delete(id);
        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.coupons_allotment GetModel(int id)
        {
            return dal.GetModel(id);
        }

        /// <summary>
        /// 获得前几行数据
        /// </summary>
        public DataSet GetList(int Top, string strWhere, string filedOrder)
        {
            return dal.GetList(Top, strWhere, filedOrder);
        }


        /// <summary>
        /// 获得前几行数据
        /// </summary>
        public int GetCount(int coupon_id, int user_id)
        {
            return dal.GetCount(coupon_id, user_id);
        }

        /// <summary>
        /// 获得查询分页数据
        /// </summary>
        public DataSet GetList(int pageSize, int pageIndex, string strWhere, string filedOrder, out int recordCount)
        {
            return dal.GetList(pageSize, pageIndex, strWhere, filedOrder, out recordCount);
        }
        #endregion

        #region 扩展方法================================

        /// <summary>
        /// 用户充值获取添加优惠券使用记录
        /// </summary>
        public bool reachAddCouponsLog(string order_no, decimal orderAmount, string erpCode)
        {
            return dal.reachAddCouponsLog(order_no, orderAmount, erpCode);
        }

        /// <summary>
        /// 添加优惠券使用记录
        /// </summary>
        public bool AddLog(bool isUpdate, string strValue, string strWhere, string companyName, string erpCode, decimal orderAmount, int user_Id)
        {
            return dal.AddLog(isUpdate, strValue, strWhere, companyName, erpCode, orderAmount, user_Id);
        }

        /// <summary>
        /// 更新优惠券使用记录
        /// </summary>
        public bool CouponsLog(string strValue, string strWhere, string companyName, string erpCode, int order_status, string remarks)
        {
            return dal.CouponsLog(strValue, strWhere, companyName, erpCode, order_status, remarks);
        }

        /// <summary>
        /// 返回指定列
        /// </summary>
        public string GetValue(int id, string fileName)
        {
            return dal.GetValue(id, fileName);
        }

        /// <summary>
        /// 修改一列数据
        /// </summary>
        public bool UpdateField(string strValue, string strWhere)
        {
            return dal.UpdateField(strValue, strWhere);
        }

        /// <summary>
        /// 修改一列数据
        /// </summary>
        public bool UpdateField(int id, string strValue)
        {
            return dal.UpdateField(id, strValue);
        }
        /// <summary>
        /// 整组分配优惠券
        /// </summary>
        /// <param name="group_id"></param>
        /// <param name="coupons_ids"></param>
        /// <returns></returns>
        public bool allotment(int group_id, Dictionary<int, int> dic_coupons_quantity, Model.manager manager, string ip, string _action_type)
        {
            return dal.allotment(group_id, dic_coupons_quantity, manager, ip, _action_type);
        }
        /// <summary>
        /// 指定会员分配优惠券
        /// </summary>
        /// <param name="user_ids"></param>
        /// <param name="coupons_ids"></param>
        /// <returns></returns>
        public bool allotment(string user_ids, Dictionary<int, int> dic_coupons_quantity, Model.manager manager, string ip, string _action_type)
        {
            return dal.allotment(user_ids, dic_coupons_quantity, manager, ip, _action_type);
        }

        /// <summary>
        /// 指定会员分配优惠券
        /// </summary>
        /// <param name="ErpCodes">'123123','234234'……</param>
        /// <param name="coupons_ids"></param>
        /// <returns></returns>
        public bool allotmentByErpCodes(string ErpCodes, Dictionary<int, int> dic_coupons_quantity, Model.manager manager, string ip, string _action_type)
        {
            return dal.allotmentByErpCodes(ErpCodes, dic_coupons_quantity, manager, ip, _action_type);
        }

        /// <summary>
        /// 系统优惠卷处理
        /// </summary>
        /// <returns></returns>
        public void CouponsRedo()
        {
            dal.CouponsRedo();
        }


        #endregion
    }
}


